<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    console.dir(Array);

    var arr = new Array(1, 2, 3, 4);
    console.log(arr);
    // console.log(arr.constructor === Array);  // arr 是由构造函数创建的
    // console.log(arr.__proto__ === Array.prototype); // arr的[[Prototype]]指向构造函数Array的原型对象

    // arr.forEach(function (item, index, array) {
    //     console.log();
    // })

    // 模拟封装forEach
    Array.prototype.each = function (fn) {
        // this -> 调用此方法的实例化对象
        for (var i = 0; i < this.length; i++) {
            fn(this[i], i, this);
        }
    }

    arr.each(function (item, index, array) {
        // console.log(item, index, array);
        console.log(this);
    })



</script>

</html>